package fr.labri.macchiato.framework.business.finder;

import java.util.List;

import fr.labri.macchiato.framework.business.model.businessEntity.BusinessEntity;
import fr.labri.macchiato.framework.business.model.preferences.PreferenceKind;
import fr.labri.macchiato.framework.business.model.preferences.UserPreferences;
import fr.labri.macchiato.framework.business.model.product.Model;
import fr.labri.macchiato.framework.business.model.product.Offer;
import fr.labri.macchiato.framework.business.model.product.Product;

/**
 * Interface for any class able to fetch products from a database
 * 
 * @author Matthieu FOUCAULT
 *
 */
public interface ProductFinder {

	/**
	 * Asynchronous call returning a list of {@link Model}s corresponding to a keyword
	 * @param keyword
	 * @param callback
	 */
	public void getModels(String keyword, Callback<List<Model>> callback);

	/**
	 * Asynchronous call returning a list of {@link Offer}s corresponding to a keyword
	 * @param keyword
	 * @param callback
	 */
	public void getOffers(String keyword, Callback<List<Offer>> callback);
	
	/**
	 * Asynchronous call returning a list of {@link Offer}s corresponding to the given keyword and providers
	 * @param keyword
	 * @param providers
	 * @param callback
	 */
	public void getOffers(String keyword, List<BusinessEntity> providers, Callback<List<Offer>> callback);
	
	/**
	 * Asynchronous call returning the {@link Offer}s for a given EAN
	 * @param ean
	 * @param callback
	 */
	public void getOffersByEan(String ean, Callback<List<Offer>> callback);
	
	/**
	 * Asynchronous call returning the {@link Offer}s for the given EAN and providers
	 * @param ean
	 * @param providers
	 * @param callback
	 */
	public void getOffersByEan(String ean, List<BusinessEntity> providers, Callback<List<Offer>> callback);

	/**
	 * Asynchronous call returning the best offer for a {@link Product} 
	 * @param product
	 * @param preference
	 * @param callback
	 */
	public void getBestOffer(Product product, UserPreferences preference,
			Callback<Product> callback);
	
	/**
	 * Sorts a list of offers according to the user preferences, and minimizing
	 * either the price, or the distance to the shop
	 * 
	 * @param offers
	 * @param userPreferences
	 * @param preferenceKind 
	 */
	public void sortOffers(List<Offer> offers, UserPreferences userPreferences,
			PreferenceKind preferenceKind);

}
